/**
 * @作者 伟子涵
 * @微信公号 搬砖暗夜码农
 * @开源项目 $ https://gitee.com/zhouwei5208888
 * @我的博客 $ http://itzhouwei.com
 * @创建时间 2023/9/27 16:48
 */
package com.itzhouwei.rpc.client;

import com.itzhouwei.rpc.codec.RpcDecoder;
import com.itzhouwei.rpc.codec.RpcEncoder;
import com.itzhouwei.rpc.codec.RpcRequest;
import com.itzhouwei.rpc.codec.RpcResponse;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

/**
 * @description:
 * @author：zw，微信：yingshengzw
 * @date: 2023/9/27
 * @Copyright： 公众号：搬砖暗夜码农 | 博客：https://itzhouwei.com - 沉淀、分享、成长，让自己和他人都能有所收获！
 */
@SuppressWarnings("all")
public class RpcClientInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline cp = socketChannel.pipeline();
        //编解码的handler
        cp.addLast(new RpcEncoder(RpcRequest.class));

        cp.addLast(new LengthFieldBasedFrameDecoder(65536,0,4,0,0));
        cp.addLast(new RpcDecoder(RpcResponse.class));
        //实际的业务处理器 RpcClientHandler
        cp.addLast(new RpcClientHandler());
        //编解码的handler
        //实际的业务处理器 RPCClientHandler
    }
}
